<template>
  <view>
    <Table ref="table" :fetchData="fetchData">
      <template #default="{ data }">
        <uni-card @click="cardClick(item)" v-for="item in data" :title="item.titleName + item.titleType"
          :extra="item.hiddenCheckTime">
          <template #title>
            <view class="title">
              <view class="title-left">
                <view class="title-title">{{ item.titleName +'-'+ item.titleType }}</view>
                 <span class="title-times">
                  {{ stateText(item) }}
                </span>
              </view>
            </view>
          </template>
          <text class="uni-body">{{ item.titleInfo }}</text>
        </uni-card>
      </template>
    </Table>

  </view>
</template>

<script setup>
import { ref, onActivated } from "vue"
import Table from "@/components/uniList.vue"
import { useAsyncData } from "@/hooks/useAsyncData.js"
import { apis as APIS } from "@/api/task.js"
import { router } from "@/router/index.js"
// import { PATH } from "../paths";
import { useUserStore } from "@/store/modules/user.js";
const userInfo = useUserStore()
const paths = {
  排查任务: '/pages/yhpc/pcjh/detail',
  计划任务: '/pages/yhpc/pcjhrw/detail',
  复核: '/pages/yhpc/yhzg/components/input',
  整改: '/pages/yhpc/yhzg/components/input',
  巡检任务: '/pages/znxj/xjrw/pointList',
}
const cardClick = (item) => {
  const path = paths[item.titleType]
  if(!path) return
  router.toPage({
    path: paths[item.titleType],
    params: {
      id: item.sourceId,
      pid: item.sourceId,
    },
  })
}
const table = ref()
const { fetchData, getList, queryParams } = useAsyncData({
  table, APIS: {
    ...APIS,
  },
  filterForm: {
     executorId: userInfo.userId,
  }
})
const stateText = (item) => {
  const pcs = ['排查任务','计划任务','复核','整改','巡检任务']
  if(pcs.includes(item.titleType)) {
    return '请处理'
  } else {
    return '请前往PC办理'
  }
}
onActivated(() => {
  getList()
})
</script>

<style lang="scss" scoped>
.title{
  display: flex;
  justify-content: space-between;
  &-left {
    display: flex;
  justify-content: space-between;
  align-items: flex-end;
  }
  &-times {
    background-color: rgb(22, 119, 255);
    padding: 2px;
    font-size: 12px;
    border-top-left-radius: 10px;
    border-bottom-right-radius: 10px;
    margin-left: 5px;
    color: #fff;
  }
}
</style>
